<?
    /*
     * Destination
     */
    $dest_hot = lang('form.dest_region');

    if (isset($_GET['dest_hot']) && ($_GET['dest_hot'] != -1 ) && ($_GET['dest_hot'] != "" ))
        $dest_hot = $_GET['dest_hot'];

    /*
     * Checkin, Checkout
     */
    $check_in = date('d.m.Y', strtotime("+1 day"));

    if (isset($_GET['check_in']))
        $check_in = $_GET['check_in'];

    $check_out = date('d.m.Y', strtotime("+2 day"));

    if (isset($_GET['check_out']))
        $check_out = $_GET['check_out'];

    /*
     * Number persons
     */
    $sel_text = 'selected = "selected"';

    if (isset($_GET['nr_adults'])) {
        $selected = $_GET['nr_adults'];
        $cnt = (isset($_GET['acc_type']) && $_GET['acc_type'] == 'hotel') ? 5 : 12;
    } else if (isset($_GET['acc_type']) && $_GET['acc_type'] == 'hotel') {
        $selected = 2;
        $cnt = 5;
    } else {
        $selected = 4;
        $cnt = 12;
    }
?>
<form action="<?= lang_url('search') ?>" method="GET" id="search_form" class='form_<?= $this->lang->mci_current() ?>'>
    <h4 class="ellipsis">Accommodation search</h4>
    <div class="simple_form">

        <div class="clearfix">
            <label>Accommodation type</label>
            <div class="input">
                <select name="acc_type" id="acc_type">
                    <option value="appartment" <? if (isset($_GET['acc_type']) && $_GET['acc_type'] == 'appartment') echo $sel_text; ?>><?= lang('form.private'); ?></option>
                    <option value="authentic accommodation" <? if (isset($_GET['acc_type']) && $_GET['acc_type'] == 'authentic accommodation') echo $sel_text; ?>><?= lang('form.authentic'); ?></option>
                    <option value="hotel" <? if (isset($_GET['acc_type']) && $_GET['acc_type'] == 'hotel') echo $sel_text; ?>><?= lang('nav.hotels'); ?></option>
                    <option value="youth hostel" <? if (isset($_GET['acc_type']) && $_GET['acc_type'] == 'youth hostel') echo $sel_text; ?>><?= lang('nav.hostels'); ?></option>
                </select>
            </div>
        </div>
        <div class="clearfix">
            <label>Destination</label>
            <div class="input clearfix">
                <input type="text" class="" value="<?= $dest_hot ?>" name="dest_hot" id="dest_hot">
            </div>
        </div>
        <div class="clearfix">
            <label>Arrival</label>
            <div class="input clearfix">
                <input type="text" value="<?= $check_in ?>" name="check_in" id="check_in" class="checkinout">
            </div>
        </div>
        <div class="clearfix">
            <label>Departure</label>
            <div class="input clearfix">
                <input type="text" value="<?= $check_out ?>" name="check_out" id="check_out" class="checkinout">
            </div>
        </div>
        <div class="clearfix">
            <label>Number of persons</label>
            <div class="input">
                <select name="nr_adults" id="nr_adults">
                    <? for ($index = 1; $index <= $cnt; $index++): ?>
                            <option value = "<?= $index ?>" <? if ($selected == $index) echo $sel_text; ?>><?= $index ?> <?= $index == 1 ? lang('form.person') : ($index > 4 && $this->lang->mci_current() == 'me') ? lang('form.person') : lang('form.persons'); ?></option>
                        <? endfor; ?>
                </select><br>
                <span class = "help-block pull-left">(<?= lang('form.excl'); ?> 0-2)</span>
            </div>
        </div>
        <div class="form-actions">
            <button class="button" type="submit" id="submit"><span><?= lang('form.search'); ?></span></button>
        </div><!--/ actions-->
    </div>
</form>